package com.zx.auth.block.mapstruct;

import com.zx.auth.block.modle.OAuth2Authorization;
import com.zx.auth.block.vo.OAuth2AuthorizationVO;
import org.mapstruct.AfterMapping;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

/**
 * <p>
 * description: OAuth2授权令牌MapStruct映射器 <br>
 * create: 2025-11-12 16:05
 * </p>
 *
 * @author
 */
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface OAuth2AuthorizationMapStructMapper {
    OAuth2AuthorizationMapStructMapper INSTANCE = Mappers.getMapper(OAuth2AuthorizationMapStructMapper.class);

    /**
     * 将OAuth2Authorization实体转换为OAuth2AuthorizationVO视图对象
     *
     * @param authorization 授权实体
     * @return OAuth2AuthorizationVO视图对象
     */
    OAuth2AuthorizationVO authorizationToAuthorizationVO(OAuth2Authorization authorization);

    /**
     * 在映射完成后，设置描述性字段
     *
     * @param authorization   授权实体
     * @param authorizationVO 授权VO
     */
    @AfterMapping
    default void setDescriptions(OAuth2Authorization authorization, @MappingTarget OAuth2AuthorizationVO authorizationVO) {
        // 可以在这里设置额外的描述性字段
        // 例如通过客户端ID查询客户端名称等
    }
}